main(n,k,r,t)
{
	for(;~scanf("%d%d",&n,&k);printf("%d\n",r))
		for(r=1,printf("%10c %10c %c\n",'K','N','R');
				n>1;n=n<k?n:k,r*=k%n?1:n,k/=k%n?1:n,t=k%n?k%n:1,n-=n-t<t?n-t:t,
				printf("%10d %10d %d\n",k,n,r));
}
